/*
 * Copyright (c) 2024 AlgoIdeas <yu19881234@163.com>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef BLE_SERVER_H
#define BLE_SERVER_H

#include <stdint.h>
#include "errcode.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */

/* Service UUID */
#define BLE_UUID_SERVER_SERVICE 0x00EE
/* Characteristic UUID */
#define BLE_CHARACTERISTIC_UUID_TX 0xCDEF
/* Characteristic UUID */
#define BLE_CHARACTERISTIC_UUID_RX 0xEFEF
/* Client Characteristic Configuration UUID */
#define BLE_CLIENT_CHARACTERISTIC_CONFIGURATION 0x2902

/* Callback receive read callback*/
typedef void (*ble_server_register_receive_read_callback)(uint8_t server_id, uint16_t conn_id, gatts_req_read_cb_t *read_cb_para,
    errcode_t status);

/* Callback receive write callback*/
typedef void (*ble_server_register_receive_write_callback)(uint8_t server_id, uint16_t conn_id, uint8_t *buffer, uint16_t length);

void ble_set_device_name_value(const uint8_t *name, const uint8_t len);
void ble_set_device_appearance_value(uint16_t appearance);
void ble_server_init(void);
errcode_t ble_server_send_input_report(uint8_t *data, uint16_t len);
uint8_t ble_get_connection_state(void);
void ble_server_register_receive_callback(ble_server_register_receive_read_callback read_callback, 
        ble_server_register_receive_write_callback write_callback);

#ifdef __cplusplus
#if __cplusplus
}
#endif  /* __cplusplus */
#endif  /* __cplusplus */
#endif